'use strict';

import { ServiceBase, Exceptions } from '../kalend';
import { datadictionaryModel } from '../model/datadictionary';

class DatadictionaryService extends ServiceBase {
    constructor() {
        super(datadictionaryModel)
    }
    async querybyKey(key: any) {
        let data: any = await this.querySingle({ key: key });
        if (data) {
            return data.value;
        } else {
            throw Exceptions.known('信息未配置或已删除');
        }
    }
    async queryBycode(key: any){
        return this.querySingle({ key: key });
    }
}

export const datadictionaryService = new DatadictionaryService();